import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingQueue;

public class ListNode {
    static void staircase(int n) {
        if(n==0){
            return ;
        }
        if(n==1){
            System.out.println("#");
        }
        for(int i=1;i<=n;i++){
            //print n-i+1 space
            for(int j=0;j<n-i;j++){
                System.out.print(" ");
            }
            //print
            for(int k=0;k<i;k++){
                if(k!=i-1){
                    System.out.print("#");
                }else{
                    System.out.println("#");
                }
            }
        }

    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int[] a = new int[]{1,2,3,4,5} ;
        int d = 4;
        int[] result = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            if(i<d){
                result[a.length-d+i] = a[i];
            }else {
                result[i-d] = a[i];
            }
        }

        for (int s: result) {
            System.out.print (s+" ");
        }
    }

}
